package com.lhkj.ct.meta.modules.questionnaire.model.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.lhkj.ct.base.json.databind.BaseEnumWritingByLabelSerializer;
import com.lhkj.ct.meta.modules.gauge.common.enums.QuestionType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
  * <p>
  *     描述：问卷调查 - 统计分析
  * </p>
  */
@Data
public class QuestionnaireStatisticsVo implements Serializable {

    @ApiModelProperty(value = "问卷id")
    private String qnrId;

    @ApiModelProperty(value = "问卷名称")
    private String qnrName;

    @ApiModelProperty(value = "共计多少份")
    private int total;

    @ApiModelProperty(value = "总平均分")
    private double totalAvg;

    @ApiModelProperty(value = "最早提交时间")
    private LocalDateTime minTime;

    @ApiModelProperty(value = "最晚提交时间")
    private LocalDateTime maxTime;

    @ApiModelProperty(value = "题目信息")
    List<Question> questions;

    @ApiModelProperty(value = "性别比例")
    private List<SexRatio> sexRatios;

    @ApiModelProperty(value = "年龄段比例")
    private List<AgeRatio> ageRatios;

    @Setter
    @Getter
    public static class SexRatio{
        private String name;

        private int value;
    }

    @Setter
    @Getter
    public static class AgeRatio{
        private String name;

        private int value;
    }

    @Data
    @Accessors(chain = true)
    public static class Question {

        @ApiModelProperty(value = "题目id")
        private String qutId;

        @ApiModelProperty(value = "题目")
        private String qutTitle;

        @ApiModelProperty(value = "题目类型")
        private QuestionType type;

        @ApiModelProperty(value = "题目类型名称")
        @JsonSerialize(using = BaseEnumWritingByLabelSerializer.class)
        private QuestionType typeName;

        @ApiModelProperty(value = "平均分")
        private double avg;

        @ApiModelProperty(value = "做答人数")
        private int counts;

        @ApiModelProperty(value = "选项")
        private List<Option> options;

        @Data
        @Accessors(chain = true)
        public static class Option {

            @ApiModelProperty(value = "选项id")
            private String optId;

            @ApiModelProperty(value = "选项内容")
            private String optTitle;

            @ApiModelProperty(value = "选项分值")
            private Double optValue;

            @ApiModelProperty(value = "比例")
            private String percent;

            @ApiModelProperty(value = "小计")
            private int subtotal;
        }
    }
}
